export const formatRelativeDate = (dateString: string): string => {
  const date = new Date(dateString);
  const now = new Date();
  
  // 重置时间为0点0分0秒，以便比较日期
  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
  const yesterday = new Date(today);
  yesterday.setDate(yesterday.getDate() - 1);
  const dayBeforeYesterday = new Date(today);
  dayBeforeYesterday.setDate(dayBeforeYesterday.getDate() - 2);
  
  const inputDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  
  // 格式化时间部分
  const timeStr = date.toLocaleString('zh-CN', {
    hour: '2-digit',
    minute: '2-digit'
  });
  
  if (inputDate.getTime() === today.getTime()) {
    return `今天 ${timeStr}`;
  } else if (inputDate.getTime() === yesterday.getTime()) {
    return `昨天 ${timeStr}`;
  } else if (inputDate.getTime() === dayBeforeYesterday.getTime()) {
    return `前天 ${timeStr}`;
  }
  
  // 其他日期保持原样
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  });
};